home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip1292.zip / CHANGPRN.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  1KB  |  53 lines

  1. /*
  2. **  change_prn()
  3. **
  4. **  A function to change the standard printer device for the duration
  5. **  of a program. Valid new device codes are:
  6. **
  7. **      0 - LPT1
  8. **      1 - LPT2
  9. **      2 - LPT3
  10. **      3 - COM1
  11. **      4 - COM2
  12. **      5 - CON
  13. **
  14. **  Original Copyright 1988-1991 by Bob Stout as part of
  15. **  the MicroFirm Function Library (MFL)
  16. **
  17. **  This subset version is functionally identical to the
  18. **  version originally published by the author in Tech Specialist
  19. **  magazine and is hereby donated to the public domain.
  20. */
  21.  
  22. #include <stdio.h>
  23.  
  24. int change_prn(int device)
  25. {
  26.       char *newdev;
  27.  
  28.       switch (device)
  29.       {
  30.       case 0:
  31.             newdev = "LPT1";
  32.             break;
  33.       case 1:
  34.             newdev = "LPT2";
  35.             break;
  36.       case 2:
  37.             newdev = "LPT3";
  38.             break;
  39.       case 3:
  40.             newdev = "COM1";
  41.             break;
  42.       case 4:
  43.             newdev = "COM2";
  44.             break;
  45.       case 5:
  46.             newdev = "CON";
  47.             break;
  48.       default:
  49.             return -1;
  50.       }
  51.       return (NULL == freopen(newdev, "w", stdprn));
  52. }
  53.